{% extends 'base.html' %}

{% block content %}
<div class="container">
    <section class="mb-5">
        <h2 class="mb-4">热门推荐</h2>
        <div class="row">
            {% for movie in recommended_movies %}
            <div class="col-md-4 mb-4">
                <div class="card h-100">
                    {% if movie.poster_url %}
                    <img src="{{ movie.poster_url }}" class="card-img-top" alt="{{ movie.title }}">
                    {% endif %}
                    <div class="card-body">
                        <h5 class="card-title">{{ movie.title }}</h5>
                        <p class="card-text">
                            <small class="text-muted">{{ movie.year }}</small>
                            {% if movie.rating %}
                            <span class="badge badge-warning float-right">{{ "%.1f"|format(movie.rating) }}</span>
                            {% endif %}
                        </p>
                        {% if movie.description %}
                        <p class="card-text">{{ movie.description[:100] }}...</p>
                        {% endif %}
                        <div class="btn-group">
                            {% if movie.play_url %}
                            <a href="{{ movie.play_url }}" class="btn btn-primary btn-sm" target="_blank">观看</a>
                            {% endif %}
                            {% if current_user.is_authenticated %}
                            <a href="{{ url_for('edit', movie_id=movie.id) }}" class="btn btn-secondary btn-sm">编辑</a>
                            {% endif %}
                        </div>
                    </div>
                </div>
            </div>
            {% endfor %}
        </div>
    </section>

    <section class="mb-5">
        <h2 class="mb-4">动作电影</h2>
        <div class="row">
            {% for movie in action_movies %}
            <div class="col-md-4 mb-4">
                <div class="card h-100">
                    {% if movie.poster_url %}
                    <img src="{{ movie.poster_url }}" class="card-img-top" alt="{{ movie.title }}">
                    {% endif %}
                    <div class="card-body">
                        <h5 class="card-title">{{ movie.title }}</h5>
                        <p class="card-text">
                            <small class="text-muted">{{ movie.year }}</small>
                            {% if movie.rating %}
                            <span class="badge badge-warning float-right">{{ "%.1f"|format(movie.rating) }}</span>
                            {% endif %}
                        </p>
                        {% if movie.description %}
                        <p class="card-text">{{ movie.description[:100] }}...</p>
                        {% endif %}
                        <div class="btn-group">
                            {% if movie.play_url %}
                            <a href="{{ movie.play_url }}" class="btn btn-primary btn-sm" target="_blank">观看</a>
                            {% endif %}
                            {% if current_user.is_authenticated %}
                            <a href="{{ url_for('edit', movie_id=movie.id) }}" class="btn btn-secondary btn-sm">编辑</a>
                            {% endif %}
                        </div>
                    </div>
                </div>
            </div>
            {% endfor %}
        </div>
    </section>

    <section class="mb-5">
        <h2 class="mb-4">喜剧电影</h2>
        <div class="row">
            {% for movie in comedy_movies %}
            <div class="col-md-4 mb-4">
                <div class="card h-100">
                    {% if movie.poster_url %}
                    <img src="{{ movie.poster_url }}" class="card-img-top" alt="{{ movie.title }}">
                    {% endif %}
                    <div class="card-body">
                        <h5 class="card-title">{{ movie.title }}</h5>
                        <p class="card-text">
                            <small class="text-muted">{{ movie.year }}</small>
                            {% if movie.rating %}
                            <span class="badge badge-warning float-right">{{ "%.1f"|format(movie.rating) }}</span>
                            {% endif %}
                        </p>
                        {% if movie.description %}
                        <p class="card-text">{{ movie.description[:100] }}...</p>
                        {% endif %}
                        <div class="btn-group">
                            {% if movie.play_url %}
                            <a href="{{ movie.play_url }}" class="btn btn-primary btn-sm" target="_blank">观看</a>
                            {% endif %}
                            {% if current_user.is_authenticated %}
                            <a href="{{ url_for('edit', movie_id=movie.id) }}" class="btn btn-secondary btn-sm">编辑</a>
                            {% endif %}
                        </div>
                    </div>
                </div>
            </div>
            {% endfor %}
        </div>
    </section>

    <section class="mb-5">
        <h2 class="mb-4">剧情片</h2>
        <div class="row">
            {% for movie in drama_movies %}
            <div class="col-md-4 mb-4">
                <div class="card h-100">
                    {% if movie.poster_url %}
                    <img src="{{ movie.poster_url }}" class="card-img-top" alt="{{ movie.title }}">
                    {% endif %}
                    <div class="card-body">
                        <h5 class="card-title">{{ movie.title }}</h5>
                        <p class="card-text">
                            <small class="text-muted">{{ movie.year }}</small>
                            {% if movie.rating %}
                            <span class="badge badge-warning float-right">{{ "%.1f"|format(movie.rating) }}</span>
                            {% endif %}
                        </p>
                        {% if movie.description %}
                        <p class="card-text">{{ movie.description[:100] }}...</p>
                        {% endif %}
                        <div class="btn-group">
                            {% if movie.play_url %}
                            <a href="{{ movie.play_url }}" class="btn btn-primary btn-sm" target="_blank">观看</a>
                            {% endif %}
                            {% if current_user.is_authenticated %}
                            <a href="{{ url_for('edit', movie_id=movie.id) }}" class="btn btn-secondary btn-sm">编辑</a>
                            {% endif %}
                        </div>
                    </div>
                </div>
            </div>
            {% endfor %}
        </div>
    </section>
</div>

<style>
.card-img-top {
    height: 300px;
    object-fit: cover;
}
</style>
{% endblock %} 